package com.zx.game2048;

import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private TextView tvScore, modelshow_text;
    GameView game_view;


    private static MainActivity mainActivity = null;

    public static MainActivity getMainActivity() {
        return mainActivity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainActivity = this;
        setContentView(R.layout.activity_main);
        tvScore = (TextView) findViewById(R.id.tvScore);
        modelshow_text = (TextView) findViewById(R.id.modelshow_text);
        game_view = (GameView) findViewById(R.id.game_view);
    }

    private int score = 0;

    public void clearScore() {
        score = 0;
        showScroe();
    }

    public void addScre(int add) {
        score = score + add;
        showScroe();
    }

    public void showScroe() {
        tvScore.setText("" + score);
    }

    public void reStart(View view) {
        game_view.startGame();
    }

    public void switchModelEasy(View view) {
        game_view.setAfterSwitch(new GameView.AfterSwitch() {
            @Override
            public void after() {
                modelshow_text.setText("简单模式");
            }
        });
        game_view.switchModel(GameView.EASY);

    }

    public void switchModelHard(View view) {
        game_view.setAfterSwitch(new GameView.AfterSwitch() {
            @Override
            public void after() {
                modelshow_text.setText("困难模式");
            }
        });
        game_view.switchModel(GameView.HARD);

    }
}
